"""
Functions and values that always should be present in the templates
"""
__revision__ = "$Id: templatehelpers.py 34 2007-02-12 12:35:22Z jens.persson $"
import turbogears
from worde import model

def get_config(name, default=""):
    """
    Fetch a configuration value
    """
    value = model.Configuration.select(model.Configuration.q.name == name)
    if value.count > 0:
        return value[0].value
    else:
        return default

def add_custom_stdvars(variables):
    """Add the functions to the namespace"""
    return variables.update({"get_config": get_config})

turbogears.view.variable_providers.append(add_custom_stdvars)